package com.zyh.service.impl;

import com.zyh.dao.IUserDao;
import com.zyh.service.IUserService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * @author cyrus
 */
@Service
public class UserServiceImpl implements IUserService {

    // 先根据类型注入，如果这个类型有多个Bean，再根据名字注入
//    @Autowired
//    @Qualifier("userDaoImpl2")
    @Resource(name = "userDao")
    private IUserDao userDao123;
//
//    public UserServiceImpl(@Qualifier("userDao") IUserDao userDao123) {
//        this.userDao123 = userDao123;
//    }

//    @Value("root")
//    private String username;
//    @Value("root")
//    private String password;

    @Value("${jdbc.username}")
    private String username;
    // 支持设置默认值，设置了默认值为root321
    @Value("${jdbc.password:root321}")
    private String password;

    @Override
    public void print() {
        System.out.println(username);
        System.out.println(password);
        userDao123.print();
    }
}
